package com.youxue.teachin.common.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import com.youxue.teachin.R;

/**
 * 在此写用途
 *
 * @author: zhiwei
 * @date: 2017-10-15 21:52
 * @version: 9.1.0
 */
public class AppUtils {
    /**
     * 获取版本号
     * @return 当前应用的版本号
     */
    public static String getVersion(Context context) {
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            String version = info.versionName;
            return version;
        } catch (Exception e) {
            e.printStackTrace();
            return context.getResources().getString(R.string.can_not_find_version_name);
        }
    }
}
